﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media.Imaging;

namespace XmlStudio.Dialogs {
    /// <summary>
    /// Interaction logic for ApplicationExitDialog.xaml
    /// </summary>
    // ReSharper disable RedundantExtendsListEntry
    public partial class ApplicationExitDialog : Window {
        // ReSharper restore RedundantExtendsListEntry
        private CancelEventArgs argument;

        protected override void OnInitialized(EventArgs e) {
            base.OnInitialized(e);

            System.Drawing.Icon icon = System.Drawing.SystemIcons.Exclamation;
            BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            warningImage.Source = bs;
        }

        public ApplicationExitDialog(CancelEventArgs argument) {
            InitializeComponent();
            this.argument = argument;
        }

        protected void OnYesClicked(object sender, EventArgs e) {
            this.DialogResult = true;
            this.Close();
        }

        protected void OnNoClicked(object sender, EventArgs e) {
            this.DialogResult = null;
            this.Close();
        }

        protected void OnCancelClicked(object sender, EventArgs e) {
            this.argument.Cancel = true;
        }
    }
}
